Skip to content

Fix crash in oblique_proj on NumPy 2 - #5

Open
HugoFara wants to merge 1 commit into
QuentinRodier:mainfrom
HugoFara:fix/numpy2-scalar-assignment
Open

Fix crash in oblique_proj on NumPy 2#5
HugoFara wants to merge 1 commit into
QuentinRodier:mainfrom
HugoFara:fix/numpy2-scalar-assignment

Conversation

@HugoFara

Copy link
Copy Markdown

RectBivariateSpline.ev returns a shape-(1,) array, assigned into a scalar element of out_var. NumPy 1.x warned; NumPy 2 raises, and setup.py allows numpy>=1.26.4 uncapped:

ValueError: setting an array element with a sequence.

Both the 3D and 2D branches fail, so oblique_proj is unusable on a fresh install. Fixed with .item().

Verified on NumPy 2.5.2 — reproduced on main, both paths pass after.

Meso-NH already carries this fix in its copy at src/LIB/Python/misc_functions.py; this makes the two files identical again.

RectBivariateSpline.ev returns a shape-(1,) ndarray, not a scalar.
Assigning it to a scalar element of out_var was tolerated by NumPy 1.x
(DeprecationWarning since 1.25) but is an error on NumPy 2:

    ValueError: setting an array element with a sequence

This makes oblique_proj unusable for both the 3D and 2D paths on any
current installation. setup.py requires numpy>=1.26.4 with no upper
bound, so a fresh install picks up NumPy 2 and the function raises.

Reproduced with Python 3.14.6, NumPy 2.4.6, SciPy 1.18.0.

Meso-NH already carries this fix in its in-tree copy of the module
(src/LIB/Python/misc_functions.py); this ports it back so the two
copies match byte for byte again.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant